home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Converters / Convert_PICT / Source / CommentedPSCode / RCS / Arcs,v next >
Encoding:
Text File  |  1995-06-12  |  11.9 KB  |  572 lines

  1. head     1.8;
  2. branch   ;
  3. access   ;
  4. symbols  beta10:1.7;
  5. locks    death:1.8;
  6. comment  @# @;
  7.  
  8.  
  9. 1.8
  10. date     93.04.04.23.30.31;  author death;  state Exp;
  11. branches ;
  12. next     1.7;
  13.  
  14. 1.7
  15. date     93.01.09.21.07.24;  author death;  state Exp;
  16. branches ;
  17. next     1.6;
  18.  
  19. 1.6
  20. date     93.01.01.11.51.32;  author death;  state Exp;
  21. branches ;
  22. next     1.5;
  23.  
  24. 1.5
  25. date     92.12.31.15.34.11;  author death;  state Exp;
  26. branches ;
  27. next     1.4;
  28.  
  29. 1.4
  30. date     92.12.05.23.07.20;  author death;  state Exp;
  31. branches ;
  32. next     1.3;
  33.  
  34. 1.3
  35. date     92.12.03.18.01.48;  author death;  state Exp;
  36. branches ;
  37. next     1.2;
  38.  
  39. 1.2
  40. date     92.11.27.19.37.53;  author death;  state Exp;
  41. branches ;
  42. next     1.1;
  43.  
  44. 1.1
  45. date     92.11.08.09.28.46;  author death;  state Exp;
  46. branches ;
  47. next     ;
  48.  
  49.  
  50. desc
  51. @@
  52.  
  53.  
  54. 1.8
  55. log
  56. @Sun Apr  4 23:30:31 PDT 1993
  57. @
  58. text
  59. @%BEGIN Arcs
  60.  
  61. %
  62. %    Note:
  63. %    setupForArcPath, penWidth and penHeight defined in Common file
  64. %
  65.  
  66. %%%%%%%%%%%%%
  67. %    Name:    arcpath
  68. %    Syntax:    top left bottom right start stop arcpath -
  69. %    About:    Given the coordinates for a rectangle, a start and finish angle,
  70. %            build a PICT style wedge/arc.  Note that we rely on the Common
  71. %            setupForArcPath to do the necessary scaling of user space.
  72. %            Note: this uses and sets the 'global' last* variables.
  73. %%%%%%%%%%%%%
  74. /arcpath
  75. {
  76.     /finishAng exch def
  77.     /startAng exch def
  78.     /lastright exch def
  79.     /lastbottom exch def
  80.     /lastleft exch def
  81.     /lasttop exch def
  82.     %
  83.     %    produce an arc-wedge along the specified angles.
  84.     %
  85.     newpath        
  86.         lastright lastleft sub    % compute width & height
  87.         lastbottom lasttop sub
  88.         lastbottom lastleft setupForArcPath
  89.         /radius exch def
  90.         /yoffset exch def
  91.         /xoffset exch def
  92.         xoffset yoffset moveto
  93.         xoffset yoffset radius startAng finishAng arc
  94.     closepath
  95. }
  96. def
  97.  
  98. %%%%%%%%%%%%%
  99. %    Name:    frameArc        [0060]
  100. %    Syntax:    top left bottom right start-angle stop-angle frameArc -
  101. %    About:    Use coords of a rectangle, plus the starting and finishing
  102. %        angle, and frames the outline of a portion of an oval's outline
  103. %        (an arc), using the values of penWidth and penHeight.
  104. %        If the penwidth and height are both 1, then we do a special case
  105. %        framing, because it looks a bit better, and will doubtlessly be
  106. %        used frequently.  Otherwise, we use the setupForArcPath routine
  107. %        to build an oval path which we then frame part of.
  108. %        Note: to get the penwidth and heigh effect, we frame an arc inside
  109. %        the first, and then fill the space between them.
  110. %        Note that the last* values are modified and used here
  111. %%%%%%%%%%%%%
  112. /frameArc
  113. {
  114.     /finishAng exch def
  115.     /startAng exch def
  116.     /lastright exch def
  117.     /lastbottom exch def
  118.     /lastleft exch def
  119.     /lasttop exch def
  120.     
  121.     gsave
  122.         penPattern usePattern
  123.         
  124.         /thewidth lastright lastleft sub def
  125.         /theheight lastbottom lasttop sub def
  126.         %
  127.         %    special case for pens that are 1 by 1 pixel
  128.         %
  129.         penHeight 1 eq
  130.         penWidth 1 eq
  131.         and
  132.         {
  133.             newpath
  134.                 thewidth theheight lastbottom lastleft setupForArcPath
  135.                 startAng finishAng arc
  136.             stroke
  137.         }
  138.         {
  139.             %
  140.             %    More general case for penwidths and heights != 1
  141.             %
  142.             penHeight 0 gt    % We don't want to draw with a 0 sized pen.
  143.             penWidth 0 gt
  144.             and
  145.             {
  146.                 /startmatrix  matrix  currentmatrix def
  147.                 newpath
  148.                     thewidth theheight lastbottom lastleft setupForArcPath
  149.                     startAng finishAng arc
  150.                     %
  151.                     %    Recover from the distortions to user space that
  152.                     %    setupForArcPath did, and calculate the dimensions
  153.                     %    of an inner rectangle bounding the arc's oval.
  154.                     %                    
  155.                     startmatrix setmatrix
  156.  
  157.                     /innerRight lastright penWidth sub 1 add def
  158.                     /innerTop  lasttop penHeight add 1 sub def
  159.                     /innerLeft lastleft penWidth add 1 sub def
  160.                     /innerBottom lastbottom penHeight sub 1 add def
  161.                     /innerWidth innerRight innerLeft sub def
  162.                     /innerHeight innerBottom innerTop sub def
  163.                     
  164.                     innerWidth innerHeight innerBottom innerLeft
  165.                     setupForArcPath
  166.                     finishAng startAng  arcn
  167.                 closepath
  168.                 fill
  169.             }
  170.             if
  171.         }
  172.         ifelse
  173.     grestore
  174. }
  175. def
  176.  
  177. %%%%%%%%%%%%%
  178. %    Name:    paintArc        [0061]
  179. %    Syntax:    t l b r start finish paintArc -
  180. %    About:    pass parameters to arcpath, and fill the resulting arc.
  181. %%%%%%%%%%%%%
  182. /paintArc
  183. {
  184.     gsave
  185.         penPattern usePattern
  186.         arcpath
  187.         fill
  188.     grestore
  189. }
  190. def
  191.  
  192. %%%%%%%%%%%%%
  193. %    Name:    eraseArc        [0062]
  194. %    Syntax:    t l b r start finish eraseArc -
  195. %    About:    Pass params to arcpath and fill the wedge with background pat
  196. %%%%%%%%%%%%%
  197. /eraseArc
  198. {
  199.     gsave
  200.         backPattern usePattern
  201.         arcpath
  202.         fill
  203.     grestore
  204. }
  205. def
  206.  
  207. %%%%%%%%%%%%%
  208. %    Name:    invertArc        [0063]
  209. %    Syntax:    t l b r start finish invertArc -
  210. %    About:    Calls arcpath, only to get last* values stored, 'cause we
  211. %            don't even try to invert the arc.
  212. %%%%%%%%%%%%%
  213. /invertArc
  214. {
  215.     gsave
  216.         arcpath
  217.     grestore
  218. }
  219. def
  220.  
  221. %%%%%%%%%%%%%
  222. %    Name:    fillArc        [0064]
  223. %    Syntax:    t l b r start finish fillArc -
  224. %    About:    Passes params to arcpath, and fills the resulting wedge.
  225. %%%%%%%%%%%%%
  226. /fillArc
  227. {
  228.     gsave
  229.         fillPattern usePattern
  230.         arcpath
  231.         fill
  232.     grestore
  233. }
  234. def
  235.  
  236. %%%%%%%%%%%%%
  237. %    Name:    frameSameArc    [0068]
  238. %    Syntax:    start finish frameSameArc -
  239. %    About:    Use last* values and params to frame an arc
  240. %%%%%%%%%%%%%
  241. /frameSameArc
  242.     /endAng exch def
  243.     /startAng exch def
  244.     lasttop lastleft lastbottom lastright startAng endAng frameArc
  245. }
  246. def
  247.  
  248. %%%%%%%%%%%%%
  249. %    Name:    paintSameArc    [0069]
  250. %    Syntax:    start finish paintSameArc -
  251. %    About:    Use last* values and params to paint an arc
  252. %%%%%%%%%%%%%
  253. /paintSameArc
  254.     /endAng exch def
  255.     /startAng exch def
  256.     lasttop lastleft lastbottom lastright startAng endAng paintArc
  257. }
  258. def
  259.  
  260. %%%%%%%%%%%%%
  261. %    Name:    eraseSameArc    [006A]
  262. %    Syntax:    start finish eraseSameArc -
  263. %    About:    Use last* values and params to erase an arc
  264. %%%%%%%%%%%%%
  265. /eraseSameArc
  266.     /endAng exch def
  267.     /startAng exch def
  268.     lasttop lastleft lastbottom lastright startAng endAng eraseArc
  269. }
  270. def
  271.  
  272. %%%%%%%%%%%%%
  273. %    Name:    invertSameArc    [006B]
  274. %    Syntax:    start finish invertSameArc -
  275. %    About:    Use last* values and params to (try to) invert an arc
  276. %%%%%%%%%%%%%
  277. /invertSameArc
  278.     /endAng exch def
  279.     /startAng exch def
  280.     lasttop lastleft lastbottom lastright startAng endAng invertArc
  281. }
  282. def
  283.  
  284. %%%%%%%%%%%%%
  285. %    Name:    fillSameArc        [006C]
  286. %    Syntax:    start finish fillSameArc -
  287. %    About:    Use last* values and params to (try to) fill an arc
  288. %%%%%%%%%%%%%
  289. /fillSameArc
  290.     /endAng exch def
  291.     /startAng exch def
  292.     lasttop lastleft lastbottom lastright startAng endAng fillArc
  293. }
  294. def
  295.  
  296. %END Arcs
  297. @
  298.  
  299.  
  300. 1.7
  301. log
  302. @Sat Jan  9 21:07:24 PST 1993
  303. @
  304. text
  305. @d99 4
  306. a102 4
  307.                     /innerRight lastright penWidth sub def
  308.                     /innerTop  lasttop penHeight add def
  309.                     /innerLeft lastleft penWidth add def
  310.                     /innerBottom lastbottom penHeight sub def
  311. @
  312.  
  313.  
  314. 1.6
  315. log
  316. @Fri Jan  1 11:51:32 PST 1993
  317. @
  318. text
  319. @@
  320.  
  321.  
  322. 1.5
  323. log
  324. @Thu Dec 31 15:34:11 PST 1992
  325. @
  326. text
  327. @@
  328.  
  329.  
  330. 1.4
  331. log
  332. @Sat Dec  5 23:07:19 PST 1992
  333. @
  334. text
  335. @d3 13
  336. a15 14
  337. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  338. %    utility:    arcpath
  339. %    Syntax:    top left bottom right start-angle stop-angle frameit arcpath -
  340. %    Description:
  341. %        takes a rectangle (top left bottom right), a start and finish angle values, and
  342. %        a flag indicating whether the arc is to be framed or not (whether we should
  343. %        close the path) and builds an arc from it,
  344. %        setting the last rect values in the process
  345. %        This is a bit tricky.  When oval is not a circle, we must scale the coordinate
  346. %        space so that we draw an oval shape.  This als means we must fiddle with
  347. %        numbers to determine where the center is in the scaled space.
  348. %    Weirdnesses:
  349. %        We use the lastrect globals for local variable use here...
  350. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  351. a23 3
  352.     
  353.     /thewidth lastright lastleft sub def
  354.     /theheight lastbottom lasttop sub def
  355. d28 3
  356. a30 1
  357.         thewidth theheight lastbottom lastleft setupForArcPath
  358. a36 1
  359.  
  360. d40 2
  361. a41 6
  362.  
  363.  
  364.  
  365. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  366. %    Opcode:    0060
  367. %    Name:    frameArc
  368. d43 11
  369. a53 15
  370. %    Description:
  371. %        Takes a rectangle (top left bottom right) and builds the frame (outline) of
  372. %        an oval from it, using the current penwidth and height
  373. %        This is, unfortunately, a very long routine.  It's made up of
  374. %        basically 3 parts:  A case when the penwidth and height are both 1,
  375. %        a case when the oval width is greater than the oval height, and a case when the
  376. %        oval height is greater than the oval width.  The first is provided basically as a
  377. %        special case, since this will probably be the most common case for thi to be called,
  378. %        and this case doesn't look as good if processed by the others.  In the other two
  379. %        cases, we necessarily distort user space so we can draw an oval.  Note that this
  380. %        also involves drawing an oval within the ovalso that we can produce the
  381. %        illusion of an ovalframed by different penwidths and heights.
  382. %    Weirdnesses:
  383. %        We use the lastrect globals for local variable use here...
  384. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  385. d84 1
  386. a84 1
  387.             penHeight 0 gt    % assure that we aren't trying to draw with a 0 sized pen.
  388. d92 7
  389. a98 1
  390.                     
  391. d106 2
  392. a107 2
  393.                     startmatrix setmatrix
  394.                     innerWidth innerHeight innerBottom innerLeft setupForArcPath
  395. d119 2
  396. a120 5
  397.  
  398.  
  399. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  400. %    Opcode:    0061
  401. %    Name:    paintArc
  402. d122 2
  403. a123 3
  404. %    Description:
  405. %        takes a rectangle and two angle values and paints its Arc on the screen
  406. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  407. d134 2
  408. a135 3
  409. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  410. %    Opcode:    0062
  411. %    Name:    eraseArc
  412. d137 2
  413. a138 3
  414. %    Description:
  415. %        takes a rectangle and two angle values and fills the wedge with the background color
  416. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  417. d149 2
  418. a150 3
  419. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  420. %    Opcode:    0063
  421. %    Name:    invertArc
  422. d152 3
  423. a154 4
  424. %    Description:
  425. %        takes a rectangle and two angle values and does nothing with them other
  426. %        than storing the last 'rectangle' used, implictly in arcpath.
  427. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  428. d163 2
  429. a164 4
  430.  
  431. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  432. %    Opcode:    0064
  433. %    Name:    fillArc
  434. d166 2
  435. a167 3
  436. %    Description:
  437. %        takes a rectangle and two angle values and fills the wedge they describe
  438. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  439. d178 2
  440. a179 4
  441.  
  442. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  443. %    Opcode:    0068
  444. %    Name:    frameSameArc
  445. d181 2
  446. a182 3
  447. %    Description:
  448. %        Use the last... values and two angle values to make a call to frame arc
  449. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  450. d191 2
  451. a192 4
  452.  
  453. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  454. %    Opcode:    0069
  455. %    Name:    paintSameArc
  456. d194 2
  457. a195 3
  458. %    Description:
  459. %        Use the last... values and two angle values to make a call to paint arc
  460. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  461. d204 2
  462. a205 4
  463.  
  464. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  465. %    Opcode:    006A
  466. %    Name:    eraseSameArc
  467. d207 2
  468. a208 3
  469. %    Description:
  470. %        Use the last... values and two angle values to make a call to eraseArc
  471. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  472. d217 2
  473. a218 4
  474.  
  475. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  476. %    Opcode:    006B
  477. %    Name:    invertSameArc
  478. d220 2
  479. a221 3
  480. %    Description:
  481. %        Use the last... values and two angle values to make a call to invert arc
  482. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  483. d230 2
  484. a231 4
  485.  
  486. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  487. %    Opcode:    006C
  488. %    Name:    fillSameArc
  489. d233 2
  490. a234 3
  491. %    Description:
  492. %        Use the last... values and two angle values to make a call to fill arc
  493. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  494. @
  495.  
  496.  
  497. 1.3
  498. log
  499. @Thu Dec  3 18:01:48 PST 1992
  500. @
  501. text
  502. @d75 4
  503. a78 17
  504.     penPattern usePattern
  505.     
  506.     /thewidth lastright lastleft sub def
  507.     /theheight lastbottom lasttop sub def
  508.     %
  509.     %    special case for pens that are 1 by 1 pixel
  510.     %
  511.     penHeight 1 eq
  512.     penWidth 1 eq
  513.     and
  514.     {
  515.         newpath
  516.             thewidth theheight lastbottom lastleft setupForArcPath
  517.             startAng finishAng arc
  518.         stroke
  519.     }
  520.     {
  521. d80 1
  522. a80 1
  523.         %    More general case for penwidths and heights != 1
  524. d82 2
  525. a83 2
  526.         penHeight 0 gt    % assure that we aren't trying to draw with a 0 sized pen.
  527.         penWidth 0 gt
  528. a85 1
  529.             /startmatrix  matrix  currentmatrix def
  530. d89 1
  531. a89 13
  532.                 
  533.                 /innerRight lastright penWidth sub def
  534.                 /innerTop  lasttop penHeight add def
  535.                 /innerLeft lastleft penWidth add def
  536.                 /innerBottom lastbottom penHeight sub def
  537.                 /innerWidth innerRight innerLeft sub def
  538.                 /innerHeight innerBottom innerTop sub def
  539.                 
  540.                 startmatrix setmatrix
  541.                 innerWidth innerHeight innerBottom innerLeft setupForArcPath
  542.                 finishAng startAng  arcn
  543.             closepath
  544.             fill
  545. d91 29
  546. a119 3
  547.         if
  548.     }
  549.     ifelse
  550. @
  551.  
  552.  
  553. 1.2
  554. log
  555. @Fri Nov 27 19:37:52 PST 1992
  556. @
  557. text
  558. @@
  559.  
  560.  
  561. 1.1
  562. log
  563. @Sun Nov  8 09:28:46 PST 1992
  564. @
  565. text
  566. @@
  567.